package com.join.template.core.constant;

import java.util.regex.Pattern;

/**
 * @author CAOYOU
 * @Title: 标记词
 * @date 2019/8/2010:47
 */
public class MarkedWords {
    public static final String AttrTemplateName = "模板名称";
    public static final String AttrVarcharName = "值名称";
    public static final String AttrDateFormat = "日期格式化参数";
    public static final String AttrVarcharAlias = "值名称";
    public static final String AttrJudgementConditions = "判断条件";
    public static final String AttrParamName = "参数名称";
    public static final String AttrItemName = "单项别名";
    public static final String AttrIndexName = "序号";
    public static final String AttrStatementOpener = "开始语句";
    public static final String AttrStatementTerminator = "结束语句";
    public static final String AttrSeparator = "分隔符";
    public static final String HintInputGeneratedContent = "请在填写有数据要生成内容";
    public static final String HintInputGeneratedDefaultContent = "请在填写没有数据要生成内容";


    public static String getAttrTemplateName() {
        return hint("forestgreen", AttrTemplateName);
    }

    public static String getAttrVarcharName() {
        return hint("forestgreen", AttrVarcharName);
    }

    public static String getAttrDateFormat() {
        return hint("forestgreen", AttrDateFormat);
    }

    public static String getAttrVarcharAlias() {
        return hint("forestgreen", AttrVarcharAlias);
    }

    public static String getAttrJudgementConditions() {
        return hint("forestgreen", AttrJudgementConditions);
    }

    public static String getAttrParamName() {
        return hint("forestgreen", AttrParamName);
    }

    public static String getAttrItemName() {
        return hint("forestgreen", AttrItemName);
    }

    public static String getAttrIndexName() {
        return hint("forestgreen", AttrIndexName);
    }

    public static String getAttrStatementOpener() {
        return hint("#cfcfcf", AttrStatementOpener);
    }

    public static String getAttrStatementTerminator() {
        return hint("#cfcfcf", AttrStatementTerminator);
    }

    public static String getAttrSeparator() {
        return hint("#cfcfcf", AttrSeparator);
    }

    public static String getHintInputGeneratedContent() {
        return hint("forestgreen", HintInputGeneratedContent);
    }

    public static String getHintInputGeneratedDefaultContent() {
        return hint("#cfcfcf", HintInputGeneratedDefaultContent);
    }


    public static String hint(String color, String hint) {
        String format = hint;// String.format("<span style='color:%s'>%s</span>", color, hint);
        return format;
    }


    public static String removeHint(String original, String hint) {
        if (original == null) {
            return "";
        }
        String format = "<.*?>" + hint + "</.*?>|" + hint;
        String replaceAll = Pattern.compile(format).matcher(original).replaceAll("");
        return replaceAll;
    }

    public static String removeBlankNode(CharSequence original) {
        if (original == null) {
            return "";
        }
        String format = "<p><br/></p>|<p></p>";
        String replaceAll = Pattern.compile(format).matcher(original).replaceAll("");
        return replaceAll;
    }
}
